<%@page import="accessor.FactoryAccessor"%>
<%@page import="accessor.Factory"%>
<%@include file="header.jsp" %>
<div class="break_line"></div>
<div class="break_line"></div>
<div id="content">
    <div id="title_content">UPDATE FACTORY</div>
    <form method="POST" action="../update_factory">
        <%
            FactoryAccessor factoryAccessor = new FactoryAccessor();
            int factoryID = request.getParameter("factoryID") != null ? Integer.parseInt(request.getParameter("factoryID")) : 0;
            Factory factory = factoryAccessor.getFactoryByID(factoryID);
        %>
        <% if (request.getSession().getAttribute("updateFactoryError") != null) {%>
                    <div class="form_error">
                        <% out.println(request.getSession().getAttribute("updateFactoryError"));%>
                    </div>
                    <%}%>
        <input type="hidden" name="factoryID" value="<%= factory != null ? factory.getFactoryID() : ""%>"/>
        <table class="form_content" width="100%">
            <tr>
                <td>FACTORY NAME: </td>
                <td>
                    <% if (request.getSession().getAttribute("update_factory_name") != null) {%>
                    <div class="form_error">
                        <% out.println(request.getSession().getAttribute("update_factory_name"));%>
                    </div>
                    <%}%>
                    <input type="text" name="factory_name" class="form_input" value="<%= factory != null ? factory.getFactoryName() : ""%>"/></td>
            </tr>
            <tr>
                <td></td>
                <td colspan="2"><input type="submit" name="submit" class="form_input" style="width: 100px;" value="Update"/></td>
            </tr>
        </table>
    </form>
</div>
<!--END content-->
<%@include file="footer.jsp" %>